﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        gridList();
    })
    function gridList() {
        $("#gridList").dataGrid({
            treeGrid: true,
            treeGridModel: "adjacency",
            url: "/ItemsType/GetTreeGridJson",
            ExpandColumn: "Code",
            height: $(window).height() - 90,
            colModel: [
                { label: "主键", name: "Id", hidden: true, key: true },
                { label: '名称', name: 'Name', width: 150, align: 'left' },
                { label: '编码', name: 'Code', width: 160, align: 'left' },
                { label: "备注", name: "Description", index: "Description", width: 200, align: "left" },
                { label: '排序', name: 'px', width: 40, align: 'left' },
                { label: "有效", name: "zt", width: 60, align: "left", formatter: function (cellvalue) { return cellvalue == "1" ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>"; } },
                { label: '创建人', name: 'CreatorCode', width: 60, align: 'left' },
                { label: '创建时间', name: 'CreateTime', width: 80, align: 'left', formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' } },
                { label: '最后修改', name: 'LastModifierCode', width: 60, align: 'left' },
                { label: '最后修改时间', name: 'LastModifyTime', width: 80, align: 'left', formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' } },
            ]
        });
        $("#btn_search").click(function () {
            $("#gridList").jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }

    //回车事件
    $('#txt_keyword').keydownEnterEvent(function () {
        $('#btn_search').trigger('click');
    })

</script>
<div class="topPanel" style="border: 0px;">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input type="text" id="txt_keyword" class="form-control" placeholder="名称/编码" style="width: 180px;">
                        <span class="input-group-btn">
                            <button type="button" id="btn_search" class="btn btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
</div>
